package com.netdisk.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取系统配置信息的类
 * @author jack
 *
 */
public class SystemParametersReader {
	private  static Properties prop;
	
	static{
		 prop = new Properties();
		 InputStream fi = 
				 SystemParametersReader.class.getClassLoader()
				 .getResourceAsStream("systemParameters.properties");
		 
		 try {
			prop.load(fi);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static  long getSingleUserMaxCapacity(){
		if(prop != null){
			long cap = Long.valueOf( prop.getProperty("singleUserMaxCapacity", "10") );
			return CapacityCount.countCapacityToByte(cap, CapacityCount.GB);
		}else {
			return CapacityCount.countCapacityToByte(10, CapacityCount.GB);
		}
		
	}
	public static  String getSaveDir(){
		if(prop != null){
			return prop.getProperty("saveDir", "/WEB-INF/filesystem");
		}else {
			return "/WEB-INF/filesystem";
		}
		
	}
	
	public static  long getEntrpriseUserMaxCapacity(){
		if(prop != null){
			long cap = Long.valueOf( prop.getProperty("entrpriseUserMaxCapacity", "10") );
			return CapacityCount.countCapacityToByte(cap, CapacityCount.GB);
		}else {
			return CapacityCount.countCapacityToByte(100, CapacityCount.GB);
		}
		
	}
	
	public static void main(String[] args) {
		System.out.println(getSingleUserMaxCapacity());
		System.out.println(getEntrpriseUserMaxCapacity());
	}
	
}
